<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Statics extends MY_Luckydog
{
	public function __construct()
	{
		parent::__construct();
        
        $this->load->model('luckydog/Examination_model', 'examination');
	}

/**
 * 时间统计
 * @return [type] [description]
 */
    public function question(){

        $_SESSION['v_menu'] = 'staticsQue';
        if($this->input->post()){
            $startTime = $this->input->post('startTime', TRUE);
            $endTime = $this->input->post('endTime', TRUE);
        }else{
            $startTime =  $this->input->get('startTime') ? $this->input->get('startTime') : date("Y-m-d");
            $endTime =  $this->input->get('endTime') ? $this->input->get('endTime') : date("Y-m-d");
        }

        $params=array("startTime"=>$startTime,'endTime'=>$endTime);
        $scoreList = $this->examination->getStandard($params);
        $score = $this->examination->getStandRate($scoreList);
        $returnData = array(
            "startTime"=>$startTime,
            "endTime"=>$endTime,
            "scoreList"=>$score
        );
        $this->load->view("/luckydog/statics/question", $returnData);
    }
    /*
     * 按部门查询统计
     */
    public function dept(){

        $_SESSION['v_menu'] = 'staticsDep';
        if($this->input->post()){
            $deptID = $this->input->post('deptID', TRUE);
        }else{
            $deptID = $this->input->get('deptID') ? $this->input->get('deptID') : 1;
        }
        $deptName = $this->examination->getDeptName($deptID);
        $params=array("departmentID"=>$deptID);
        $scoreList = $this->examination->getStandard($params);
        $score = $this->examination->getStandRate($scoreList);
        $doc_cat_list = $this->examination->get_cat_list();
        $returnData = array(
            "deptID"=>$deptID,
            "deptName"=>$deptName,
            "doc_cat_list"=>$doc_cat_list,
            "scoreList"=>$score
        );
        $this->load->view("/luckydog/statics/dept", $returnData);
    }
/*
 * 按用户查询统计
 */
    public function user(){

        $_SESSION['v_menu'] = 'staticsUser';
        if($this->input->post()){
            $userName = $this->input->post('userName', TRUE);
        }else{
            $userName = $this->input->get('userName') ? $this->input->get('userName') : "";
        }
        $userInfo = $this->examination->getUserID($userName);
        $params=array("userID"=>$userInfo['AccountID']);
        $scoreList = $this->examination->getStandard($params);
        $score = $this->examination->getStandRate($scoreList);

        $returnData = array(
            "userID"=>$userInfo['AccountID'],
            "userName"=>$userInfo['truename'],
            "loginName"=>$userName,
            "scoreList"=>$score
        );
        $this->load->view("/luckydog/statics/user", $returnData);
    }




}
/* End of file index.php */
/* Location: ./application/controllers/luckydog/index.php */
